package com.yuexunit.operationman.nbsy.module.BeforeAnesthesiaVisit.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.BeforeAnesthesiaVisit.bean.BeforeAnesthesiaBean;
import com.yuexunit.operationman.nbsy.module.BeforeAnesthesiaVisit.ui.Act_BeforeAnesthesiaPreview;

import org.kymjs.kjframe.ui.KJFragment;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by chenss on 2017/8/8 0008.
 */

public class Fragment_BA_Anesthesia extends KJFragment {

    @Bind(R.id.frag_ba_ane_01)
    TextView fragBaAne01;
    @Bind(R.id.frag_ba_ane_02)
    TextView fragBaAne02;
    @Bind(R.id.frag_ba_ane_03)
    TextView fragBaAne03;

    private Act_BeforeAnesthesiaPreview aty;
    protected View mMainView;

    @Override
    protected View inflaterView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
        aty = (Act_BeforeAnesthesiaPreview) getActivity();
        mMainView = inflater.inflate(R.layout.fragment_ba_anesthesia, container, false);
        ButterKnife.bind(this, mMainView);
        return mMainView;
    }

    @Override
    protected void initData() {
        for(BeforeAnesthesiaBean.ObjectEntity.VisitItemsEntity p : AppConfig.BEFOREANSETHESIA.getObject().getVisitItems()) {
            switch (p.getItemCode()) {
                case "MaZuiJiHua":
                    if (p.getItemValue().length() > 0) {
                        String[] array = p.getItemValue().split(";");
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.beforeanesthesia_01);
                        for (int i = 0; i < array.length; i++) {
                            switch (array[i]) {
                                case "1":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[0];
                                    }
                                    else {
                                        content += arrays[0];
                                    }
                                    break;
                                case "2":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[1];
                                    }
                                    else {
                                        content += arrays[1];
                                    }
                                    break;
                                case "3":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[2];
                                    }
                                    else {
                                        content += arrays[2];
                                    }
                                    break;
                                case "4":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[3];
                                    }
                                    else {
                                        content += arrays[3];
                                    }
                                    break;
                                case "5":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[4];
                                    }
                                    else {
                                        content += arrays[4];
                                    }
                                    break;
                                case "6":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[5];
                                    }
                                    else {
                                        content += arrays[5];
                                    }
                                    break;
                                case "7":
                                    if (content.length() > 0) {
                                        content += "\n";
                                        content += arrays[6];
                                    }
                                    else {
                                        content += arrays[6];
                                    }
                                    break;
                            }
                        }
                        fragBaAne01.setText(content);
                    }
                    break;
            }
        }

        fragBaAne03.setText(AppConfig.BEFOREANSETHESIA.getObject().getVisit().getSignDateStr());
        fragBaAne02.setText(AppConfig.BEFOREANSETHESIA.getObject().getVisit().getDoctorSign());
    }
}
